package main

import (
    "fmt"
    "strings"
    "unicode"
)

func analyzeString(s string) {
    // 统计字符'i'的出现次数及首次出现的下标
    iCount := 0	
    firstIndex := -1
    for i, char := range s {
        if char == 'i' || char == 'I' {
            iCount++
            if firstIndex == -1 {
                firstIndex = i
            }
        }
    }

    // 统计大写字母和小写字母的出现次数
    upperCount := 0
    lowerCount := 0
    for _, char := range s {
        if unicode.IsUpper(char) {
            upperCount++
        } else if unicode.IsLower(char) {
            lowerCount++
        }
    }

    // 统计字符串总长度
    totalLength := len(s)

    // 转换字符串：所有字母变为大写，去除标点符号和空格
    var transformed strings.Builder
    for _, char := range s {
        if unicode.IsLetter(char) {
            transformed.WriteRune(unicode.ToUpper(char))
        }
    }

    // 输出结果
    fmt.Printf("字符'i'的出现次数: %d\n", iCount)
    fmt.Printf("字符'i'首次出现的下标: %d\n", firstIndex)
    fmt.Printf("大写字母出现次数: %d\n", upperCount)
    fmt.Printf("小写字母出现次数: %d\n", lowerCount)
    fmt.Printf("字符串总长度: %d\n", totalLength)
    fmt.Printf("转换后的字符串: %s\n", transformed.String())
}

func main() {
    s := "In this course, we will learn the famous programming language GoLang"
    analyzeString(s)
}
